<template>
<h1>EL-表单组件</h1>
  <el-form style="width: 600px;margin: 0 auto;" label-width="80px">
    <el-form-item label="用户名">
      <el-input placeholder="请输入用户名" v-model="user.username"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input placeholder="请输入密码" show-password v-model="user.password"></el-input>
    </el-form-item>
    <el-form-item label="性别">
      <el-radio-group v-model="user.gender">
        <el-radio label="男" value="1"></el-radio>
        <el-radio label="女" value="2"></el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="所在地">
      <el-select v-model="user.city" placeholder="请选择" style="width: 400px;">
        <el-option label="北京" value="bj"></el-option>
        <el-option label="上海" value="sh"></el-option>
        <el-option label="广州" value="gz"></el-option>
        <el-option label="深圳" value="sz"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="管理员">
      <el-switch v-model="user.isShow"></el-switch>
    </el-form-item>
    <el-form-item>
      <el-button type="success" @click="reg">点我提交</el-button>
    </el-form-item>
  </el-form>
  <hr>
  <h1>第1题</h1>
  <p v-if="isShow1">aaaaaa</p>
  <p v-show="isShow1">bbbbbb</p>
  <button @click="isShow1 = !isShow1">切换p标签的显示状态</button>
  <hr>
  <h1>第2题</h1>
  <input type="text" placeholder="请输入图片路径" v-model="url">
  <img :src="url" alt="无效链接">
  <hr>
  <h1>第3题</h1>
  <ul v-for="(p,index) in proArr">
    <li>{{p}}<button @click="del(index)">删除</button></li>
  </ul>
</template>
<script setup>
import {ref} from "vue";
const user = ref({
  username: "",
  password: "",
  gender: "",
  city: "",
  isShow: false
});
const reg = () => {
  console.log(user.value);
}

const isShow1 = ref(true);
const url = ref("");
const proArr = ref(['苹果', '香蕉', '橘子', '葡萄' , '西瓜']);
const del = (index) => {
    proArr.value.splice(index,1);
}
</script>


<style scoped>

</style>